/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.CalendarResourceBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.AdminConstants;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.CalendarResource;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.admin.message.RenameCalendarResourceRequest;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class RenameCalendarResource
/*     */   extends AdminDocumentHandler
/*     */ {
/*  41 */   private static final String[] TARGET_RESOURCE_PATH = { "id" };
/*     */   
/*  43 */   protected String[] getProxiedResourcePath() { return TARGET_RESOURCE_PATH; }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean domainAuthSufficient(Map context)
/*     */   {
/*  51 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*     */   {
/*  59 */     return true;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*     */   {
/*  64 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  65 */     Provisioning prov = Provisioning.getInstance();
/*  66 */     RenameCalendarResourceRequest req = (RenameCalendarResourceRequest)JaxbUtil.elementToJaxb(request);
/*     */     
/*  68 */     String id = req.getId();
/*  69 */     String newName = req.getNewName();
/*     */     
/*  71 */     CalendarResource resource = prov.get(Key.CalendarResourceBy.id, id);
/*  72 */     defendAgainstCalResourceHarvesting(resource, Key.CalendarResourceBy.id, id, zsc, Rights.Admin.R_renameCalendarResource);
/*  73 */     String oldName = resource.getName();
/*     */     
/*     */ 
/*  76 */     checkAccountRight(zsc, resource, Rights.Admin.R_renameCalendarResource);
/*     */     
/*     */ 
/*  79 */     checkDomainRightByEmail(zsc, newName, Rights.Admin.R_createCalendarResource);
/*     */     
/*  81 */     prov.renameCalendarResource(id, newName);
/*     */     
/*  83 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameCalendarResource", "name", oldName, "newName", newName }));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  88 */     resource = prov.get(Key.CalendarResourceBy.id, id);
/*  89 */     if (resource == null) {
/*  90 */       throw ServiceException.FAILURE("unable to get calendar resource after rename: " + id, null);
/*     */     }
/*  92 */     Element response = zsc.createElement(AdminConstants.RENAME_CALENDAR_RESOURCE_RESPONSE);
/*  93 */     ToXML.encodeCalendarResource(response, resource, true);
/*  94 */     return response;
/*     */   }
/*     */   
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/*  99 */     relatedRights.add(Rights.Admin.R_renameCalendarResource);
/* 100 */     relatedRights.add(Rights.Admin.R_createCalendarResource);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RenameCalendarResource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */